package com.yozinga;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;

import com.yozinga.fragment.CategoryListFragment;

public class CategoryActivity extends BaseActivity implements OnClickListener{

	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		setContentView(R.layout.activity_category);
		
		((ImageView)findViewById(R.id.ivHome)).setOnClickListener(this);
		
		String screenName = getIntent().getStringExtra("categoryName");
		((TextView)findViewById(R.id.categoryName)).setText(screenName);
		CategoryListFragment restaurantListFragment = new CategoryListFragment();
		restaurantListFragment.setArguments(getIntent().getExtras());
		FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
		transaction.replace(R.id.flFragmentHolder, restaurantListFragment);
		transaction.commit();
	}
	
	@Override
	public void onClick(View v) {
		Intent homeIntent = null;
		if(v.getId() == R.id.ivHome){
			homeIntent = new Intent(this,HomeActivity.class);
			homeIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
			startActivity(homeIntent);
		}else{
			super.onClick(v);
		}
	}
	
	
}
